package com.appsys.service;

import com.appsys.dao.AppInfoMapper;
import com.appsys.pojo.AppInfo;
import com.appsys.pojo.Version;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * @ClassName AppInfoService
 * @Description TODO
 * @Author YinLiangTao Email:1517535831@qq.com
 * @Date 2022/2/26 15:10
 * @Version 1.0
 */
@Service
public class AppInfoService {
    @Resource
    private AppInfoMapper appInfoMapper;
    //获取用户id为devId的全部的app信息
    public List<AppInfo> getAppInfoByDevId(Map map){
        return appInfoMapper.getAppInfoByDevId(map);
    }
    //模糊查询
//    public AppInfo getAppInfoByLike(Map map){
//        AppInfo appInfoByLike = appInfoMapper.getAppInfoByLike(map);
//        return appInfoByLike;
//    }
    //获取全部的app信息
    public List<AppInfo> getAppInfoList(){
        return appInfoMapper.getAppInfoList();
    }

    public boolean addInfo(AppInfo appInfo){//添加信息
        if(appInfoMapper.addInfo(appInfo) > 0){
            return true;
        }
        return false;
    }
    //更新信息
    public boolean updateInfo(AppInfo appInfo){
        if (appInfoMapper.updateInfo(appInfo) >= 0){
            return true;
        }
        return false;
    }
    //更新版本信息
    public boolean updateInfoByVersion(Version version){
        Date date = new Date();
        if (appInfoMapper.updateInfoByVersion(date,version) >= 0){
            return true;
        }
        return false;
    }
    //删除app信息
    public int deleteInfo(int id){
       return appInfoMapper.deleteInfo(id);
    }
    //更新状态
    public int updateStatus(int statusId,int id){
        return appInfoMapper.updateStatus(statusId,id);
    }
    //更新状态
    public int updateStatusByappId(int appId,int statusId){
        Date date = new Date();
        return appInfoMapper.updateStatusByappId(appId,date,statusId);
    }
}
